package main;

import java.util.LinkedList;
import java.util.List;

import main.IMessagedispatcher.MessagedispatcherException;
import messages.IMessage;
import messages.IRequest;

import org.jdom.Element;

import plugins.IPlugin;
import plugins.testPlugin.TestpluginController;
import settings.Settings;

/**
 * This is the model of the mainclass of the application.
 * It contains a list of all found and active Plugins and the
 * central message-queue
 * 
 * @author daishy
 * @date 23.03.2008 19:32:41
 *
 */
public class Mainmodel implements IMessagedispatcher
{
	@Override
	public void registerGroup(String group) throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendMessage(IMessage message) throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendMessage(String group, IMessage message)
			throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendRequest(IRequest request) throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void subscribeGroup(IPlugin plugin, String group)
			throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void unregisterGroup(String group) throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void unsubscripe(IPlugin plugin, String group)
			throws MessagedispatcherException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * A list of all plugins found (Only the classobject)
	 */
	private List<Class<? extends IPlugin>> knownPlugins;
	
	/**
	 * List of all found plugins
	 */
	private List<IPlugin> loadedPlugins;
	
	/**
	 * Settings for the main-menu
	 */
	private Settings settings;
	
	/**
	 * CTor
	 */
	public Mainmodel()
	{
		this.knownPlugins = new LinkedList<Class<? extends IPlugin>>();
		this.loadedPlugins = new LinkedList<IPlugin>();
		
		// loading all plugins (-> creating a new instance of each)
		loadAvailablePlugins();
	}
	
	/**
	 * This method currently loads each plugin located in
	 * the pluginfolder (by hand) 
	 */
	public void loadAvailablePlugins()
	{
		this.loadedPlugins.add(new TestpluginController());
		
	
	}
	
	/**
	 * THis method returns the list of loaded plugins.
	 * @return List<IPlugin>
	 */
	public List<IPlugin> getLoadedPlugins() {
		return this.loadedPlugins;
	}
}
